from django.urls import re_path
from rest_framework.routers import DefaultRouter

from .views import *

router = DefaultRouter()

# 设备
router.register('devices', DevicesView)
# 485传感器
router.register('sensor', SensorView)
# 配置
router.register('config', DevicesConfigView)
# 模拟量控制
router.register('mockcontrol', MockControlView)
# 继电器
router.register('control', DevicesControllersView)
# 模拟量传感器
router.register('mocksensor', MockSensorView)
# 自动规则
router.register('autorule', AutoRuleView)
# 组合控制
router.register('controlgroup', ControlGroupView)
# 设备视频监控
router.register('devicevideo', DeviceVideoMonitorView)
# 数字量传感器
router.register('numbersensor', NumberSensorView)
# 传感器历史
router.register('history', HistoryView)

urlpatterns = router.urls + [
    re_path('reboot/(?P<pk>\d*?)/$', ReBootView.as_view()),
    re_path('autoupload/(?P<pk>\d*?)/$', AutoUploadDataView.as_view()),
    re_path('control/(?P<id>\d*?)/$', ControlActionView.as_view()),
    re_path('transmission/(?P<pk>\d*?)/$', TransmissionView.as_view()),
    re_path('statistics/$', DevicesStatisticsView.as_view())
]
